﻿using System;
using System.Collections.Generic;

namespace _05迭代器模式
{
    /// <summary>
    /// 具体聚合
    /// </summary>
    public class ConcreteAggregate<T> : IAggregate<T>
    {
        private List<T> list = new List<T>();

        public void Add(T obj)
        {
            list.Add(obj);
        }
        public void Remove(T obj)
        {
            list.Remove(obj);
        }
        /// <summary>
        /// 获取迭代器
        /// </summary>
        /// <returns></returns>
        public Iterator<T> GetIterator()
        {
            return new ConcreteIterator<T>(list);
        }

    }
}
